#/bin/bash

month='12'

echo '[info] converting to csv file ...'
awk -F'?' '{print $2}' logbmm_2013$month*.merged |
awk -F' - FIRST_UP' '{print $1}' |
awk '{split($0,arr,"&"); print(substr(arr[1],index(arr[1],"=")+1) "," substr(arr[2],index(arr[2],"=")+1) "," substr(arr[3],index(arr[3],"=")+1) "," substr(arr[4],index(arr[4],"=")+1) "," strftime("%Y-%m-%d %H:%M:%S",substr(arr[5],index(arr[5],"=")+1,10)) "," substr(arr[6],index(arr[6],"=")+1) )} ' > clicklog.csv
sed -i 's/ - NONE\/- text\/html//g' clicklog.csv
rm -f logbmm_*.merged
